Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

exec-sh

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exec-sh

Execute shell command forwarding all stdio.

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is exec-sh?

The exec-sh npm package is a simple utility for executing shell commands in Node.js. It provides a straightforward API to run shell commands synchronously or asynchronously, with options to handle output and errors.

What are exec-sh's main functionalities?

Execute a command asynchronously

This feature allows you to execute a shell command asynchronously. The callback function handles any errors and provides the exit code if the command fails.

const execSh = require('exec-sh');
execSh('echo Hello World', function(err){
  if (err) {
    console.log('Exit code:', err.code);
    return;
  }
  console.log('Command executed successfully');
});

Execute a command synchronously

This feature allows you to execute a shell command synchronously. If the command fails, an error is thrown, and you can catch it to handle the exit code.

const execSh = require('exec-sh');
try {
  execSh.sync('echo Hello World');
  console.log('Command executed successfully');
} catch (err) {
  console.log('Exit code:', err.code);
}

Capture command output

This feature allows you to capture the standard output and standard error of the executed command. The callback function provides the stdout and stderr as arguments.

const execSh = require('exec-sh');
execSh('echo Hello World', true, function(err, stdout, stderr){
  if (err) {
    console.log('Exit code:', err.code);
    return;
  }
  console.log('stdout:', stdout);
  console.log('stderr:', stderr);
});

Other packages similar to exec-sh

Keywords

FAQs

Package last updated on 26 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc